associated_form = render :partial => 'form_association_record', :locals => {:scope => @scope, :parent_record => @parent_record}
associated_form = %|<tr class="association-record #{'association-record-new' if @record.new_record?} #{'locked' if @record.new_record? and @column.singular_association?}">#{associated_form}</tr>|

if @column.singular_association?
  page << %|
    associated = #{associated_form.to_json};
    if (current = $$('##{sub_form_list_id(:association => @column.name)} tr.association-record')[0]) {
      Element.replace(current, associated)
    } else {
      new Insertion.Top('#{sub_form_list_id(:association => @column.name)}', associated)
    }
  |
else
  page.insert_html :bottom, sub_form_list_id(:association => @column.name), associated_form
end
